<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp" %>
<script src="${contextPath}/scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function checkSubmit(){
 	var staffForm = document.form1;
	if(!Validator.Validate(staffForm, 3)) {
		return false;
	}
	
	var flag = true;
	$.ajax({
		  async:false,
		  type: 'POST',
		  url: '${contextPath}/pm/assign/checkMonthListOfPersons.do',
		  dataType: "json",
		  data:{"entity.monthDate":$("#monthDateField").val(),"entity.confirmPlanDate":$("#confirmPlanDateField").val()},
		  success: function(data) {
			  if(data.data){
				  if(data.data.nopm){
						flag = false;
				  		alert(data.msg);
				  		window.location.href="${contextPath}/pm/assign/index.do";
				  		return;
				  }
				  $('#hasNotSubmitField').val(data.data.hasNotSubmit);
			  }
			  	
				//dateOver,hasNotSubmit
				if(!data.flag) {
					flag = false;
					$('#msg').html(data.msg);
					if(data.data && data.data.dateOver && data.data.hasNotSubmit){ 
						if(confirm("人员名单最后提交日期已到期，还存在人员名单未发布，是否确定继续保存生成绩效？点击确定将会根据组织架构生成绩效人员名单。")){
							flag = true;
						}
					}else if(data.data && (!data.data.dateOver) && (!data.data.hasNotSubmit)){
						if(confirm("人员名单最后提交日期还没有到期，人员名单已经发布完毕，是否确定继续保存生成绩效？")){
							flag = true;
						}
					}else{
						alert("抱歉，还未到人员名单最后提交日期，各区域经理还没发布各自人员名单，不能生成绩效。或者因为..." + data.msg);
					}
				}
		  },
		  error:function(data){
			  flag = false;
			  alert("系统错误请联系相关管理员。");
			}
		});

	return flag;
 }
//-->
</script>
	<input type='hidden' name='entity.id' value='${entity.id}' />
	<input type='hidden' name='redirectUrl' value='<s:property value='redirectUrl'/>' />
	<input type='hidden' id='hasNotSubmitField' name='hasNotSubmit' value='${hasNotSubmit}'/>
	<span style="color:red;" id="msg">
		 <s:actionerror/>
	</span>
	<table width="100%" border="0" cellpadding="1" cellspacing="1">
		<tr>
			<td class="left-td-width-bg">
				<font color="red">*</font>绩效月份:
			</td>
			<td>
				<input onFocus="WdatePicker({dateFmt:'yyyy-MM',maxDate:'${entity.monthDate}'})" name="entity.monthDate" class="Wdate" type="text" id="monthDateField" size="16" readonly="readonly"
					value="${entity.monthDate}" dataType="Require|Unique"  msg="必填项|该月已经分配过，请选择其他月份。"
						 classType="com.jysz.certificate.persistence.model.pm.PerformanceAssign" valProperty="monthDate" entityId="${entity.id}" contextPath="${contextPath}" style="width: 100px"/>
			</td>
			<td class="left-td-width-bg">
				<font color="red">*</font>最后确认时间：
			</td>
			<td>
				<input name="entity.confirmPlanDate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate" type="text" id="confirmPlanDateField" size="16" readonly="readonly"
					 value="<s:date name='entity.confirmPlanDate' format="yyyy-MM-dd"/>" dataType="Require"  msg="最后确认时间不能为空" />
			</td>			
		</tr>
	</table>
	 <table width="100%">
            	<tr>
                	<td><div align="center">
                	  <input type="submit" name="submit" value="  " class="btn_save_next" />
                	&nbsp;&nbsp;
                      <input type="reset" name="reset" value="  " class="btn_rest" onclick="clearForm(this.form);return false;"/>
                    </div>
                    </td>
                </tr>
     </table>        